//
//  BQHomeGoodsCell.m
//  BeeQuick
//
//  Created by mac on 16/11/22.
//  Copyright © 2016年 six_group. All rights reserved.
//

#import "BQHomeGoodsCell.h"
#import <UIImageView+WebCache.h>
@interface BQHomeGoodsCell()
@property (weak, nonatomic) IBOutlet UIImageView *iconView;

@property (weak, nonatomic) IBOutlet UILabel *nameLabel;

//规格
@property (weak, nonatomic) IBOutlet UILabel *sizeLabel;
//现价
@property (weak, nonatomic) IBOutlet UILabel *currentPriceLabel;

//原价
@property (weak, nonatomic) IBOutlet UILabel *marketPriceLabel;

@end
@implementation BQHomeGoodsCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.backgroundColor = [UIColor whiteColor];
}
- (IBAction)increadBtnClick:(UIButton *)sender {
    //给单例 添加一个商品
    
    NSLog(@"我点击了加号");

    [myCar addGoods:self.model];
    
    //把他的选中改为yes
    self.model.Selected = YES;
    
//    UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
//    
//    CGPoint picPoint = [self convertPoint:self.iconView.center toView:keyWindow];
//    
//    if ([_delegate respondsToSelector:@selector(rightCell:withAddModel:withStartPoint:)])
//    {
//        [_delegate rightCell:self withAddModel:_model withStartPoint:picPoint];

    UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
    
    CGPoint picPoint = [self convertPoint:self.iconView.center toView:keyWindow];

    //少一个动画
    


    if([self.delegate respondsToSelector:@selector(BQHomeGoodsCellWithStartPoint:andModel:)])
    {
        [self.delegate BQHomeGoodsCellWithStartPoint:picPoint andModel:self.model];
    }
    
    

    
    
}

-(void)setModel:(BQHomeGoodModel *)model
{
    _model = model;
    
//    //品牌
//    @property(nonatomic,copy)NSString *brand_name;
//    
//    //价格(现价)
//    @property(nonatomic,copy)NSString *price;
//    
//    @property(nonatomic,copy)NSString *img;
//    
//    //名字
//    @property(nonatomic,copy)NSString *name;
//    
//    //保质期
//    @property(nonatomic,copy)NSString *safe_day;
//    
//    //规格
//    @property(nonatomic,copy)NSString *specifics;
//    
//    //剩余数量
//    @property(nonatomic,copy)NSString *store_nums;
//    
//    //超市原价
//    @property(nonatomic,copy)NSString *market_price;

    [self.iconView sd_setImageWithURL:[NSURL URLWithString:model.img]];
    
    
    self.sizeLabel.text = model.specifics;
    
    
    self.currentPriceLabel.text = [NSString stringWithFormat:@"¥%@",model.price];
    
    
    self.marketPriceLabel.text = [NSString stringWithFormat:@"¥%@",model.market_price];
    
    self.nameLabel.text = model.name;
    
    
    
    
    
}

@end
